#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n, a[N],b[N],c[N],sum,k=1;
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;++i)
        cin>>a[i];
    sort(a+1,a+n+1);
    if(n%2==0){
        for(int i=1;i<=n/2;++i)
            b[i]=a[i];

        for(int i=n/2+1;i<=n;++i){
            c[k]=a[i];
            k++;
        }
        for(int i=1;i<=n/2;++i){
            if(c[i]>b[i]) b[i]=0;
            cout<<b[i]<<" "<<c[i]<<"\n";
        }
        for(int i=1;i<=n/2;++i)
            if(b[i]>0) sum++;
        for(int i=1;i<=n/2;++i)
            if(c[i]>0) sum++;
    }else{
        for(int i=1;i<=n/2;++i)
            b[i]=a[i];

        for(int i=n/2+1;i<=n-1;++i){
            c[k]=a[i];
            k++;
        }
        c[k+1]=a[n];
        for(int i=1;i<=n/2;++i){
            if(c[i]>b[i]) b[i]=0;
            cout<<b[i]<<" "<<c[i]<<"\n";
        }
        for(int i=1;i<=n/2;++i)
            if(b[i]>0) sum++;
        for(int i=1;i<=n/2;++i)
            if(c[i]>0) sum++;
        if(b[k+1]>b[1]) sum--;


    }
    cout<<sum;


    }







